import store from "@/store";
import { getDayData,getMonthData,getYearData } from "./request";

//获取数据
const getData =async(field,date)=>{
    let data = null
    switch(field){
        case 'day':
            data=await getDayData(date)
            break
        case 'month' :
            data=await getMonthData(date)
            break
        case 'year' :
            data=await getYearData(date)
            break
    }
let res=null
switch(field){
    case 'day':
        res=data.result.data
        break
    case 'month':
        res=data.result.data.holiday_array
        break
    case 'year':
        res=data.result.data.holiday_list
}

store.commit('seterrorCode',data.error_code)
if(data.error_code!==0){
    return
}
    store.commit('setData',{
        field,
        data:res
    })
}
export default getData